$(function() {
	$('.btn-submit').on('click', onSubmit);
}());


function onSubmit() {
	if(passed()) {
		ghttp.post('/bd/login', {
			name: $('input[name=name]').val(),
			password: $('input[name=password]').val()
		}, function(resp) {
			if(!resp.success) {
				alert(resp.result);
				return;
			}
			window.location.href = '/bd/index';
		});
	}
}

function passed() {
	var name = $('input[name=name]').val();
	var password = $('input[name=password]').val();

	if(!name) {
		alert('请输入用户名');
		return false;
	}

	if(!password) {
		alert('请输入密码');
		return false;
	}
	return true;
}